﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace yq.IBase.DBHelper
{
    /// <summary>
    /// 拼接SQL语句
    /// </summary>
    public class SelectSQL
    {
        string _Select = "select ";

        public string SelectString
        {
            get { return _Select; }
            set { _Select = value; }
        }

        string _Field = "";

        public string Field
        {
            get { return _Field; }
            set { _Field = value; }
        }

        string _Table = "";

        public string Table
        {
            get { return _Table; }
            set { _Table = value; }
        }


        string _WhereFront = "";

        /// <summary>
        /// Where之前
        /// </summary>
        public string WhereFront
        {
            get { return _WhereFront; }
            set { _WhereFront = value; }
        }


        string _Where = "";

        public string WhereString
        {
            get { return _Where; }
            set { _Where = value; }
        }

        string _OrderBy = "";

        public string OrderByString
        {
            get { return _OrderBy; }
            set { _OrderBy = value; }
        }

        /// <summary>
        /// 在最后的
        /// </summary>
        string _End = "";

        public string End
        {
            get { return _End; }
            set { _End = value; }
        }

        const string _From = " From ";

        /// <summary>
        /// 拼接字符串 Select Field from table whereFront where orderby end
        /// </summary>
        /// <returns></returns>
        public string toSql()
        {
            return _Select + _Field + _From + _Table + _WhereFront + _Where + _OrderBy + _End;
        }

        /// <summary>
        /// 拼接字符串 Select Field from table whereFront where  end
        /// </summary>
        /// <returns></returns>
        public string toSqlNoOderBy()
        {
            return _Select + _Field + _From + _Table + _WhereFront + _Where  + _End;
        }
    }
}
